Graphs of Derivatives
Second Book

This Mathematica notebook is licensed under a MouseOver .

The  notebook contains some of the code used to create the MouseOver on abstractmath.org.

GT := 3

Definition of Derivative

A real valued function f may have a derivative, which is another real valued function denoted by f'.  At a point a, f'[a] is the slope of the tangent line to the curve y = f[x] at the point (a, f[x]).

Functions used in creating the examples

ShowDerivatives[f_,n_,a_,b_] :=Plot[Take[{f[x],f'[x],f''[x],f'''[x],f''''[x]}, n] // Evaluate,{x,a,b}, Prolog->AbsoluteThickness[GT],PlotRange->{a,b}, AspectRatio->1, ImageSize -> {200,200},PlotStyle->{{RGBColor[0,0,1]}, {RGBColor[1,0,0]},{RGBColor[0,1,0]}, RGBColor[.7,.7,0],RGBColor[.7,0,.7]}]

TO DO : Make SD print each line in the appropriate color.

TO DO : Increase the type size in the SD printout.  It is not obvious how to do this.

TO DO : Bring the graph of the function to the front so that the derivatives all pass underneath it.

SD[f_,n_,a_,b_, c_, d_, s_] := ((r := (d-c)/(b-a)); Plot[Take[{f[x],f'[x],f''[x],f'''[x],f''''[x],f'''''[x]}, n] // Evaluate,{x,a,b}, PlotRange->{c,d},Prolog->AbsoluteThickness[GT], AspectRatio->r, ImageSize -> { s,r s},PlotStyle->{{RGBColor[0,0,1]}, {RGBColor[1,0,0]},{RGBColor[0,1,0]}, RGBColor[.7,.7,0],RGBColor[.7,0,.7],RGBColor[0,.7,.7]}])

The derivatives are shown in each graph by color.  
function: blue
first derivative : red
second : green
third : gold
fourth : purple
fifth: light blue

DF prints out the formulas for the derivatives

DF[f_,n_]:=
TraditionalForm[
TableForm[
Take[{{"function",f[x]},{"1st deriv",f'[x]},{"2nd deriv",f''[x]},{"3rd deriv",f'''[x]},{"4th deriv",f''''[x]},{"5th deriv",f'''''[x]},{"6th deriv",f''''''[x]}}, n]]]

Transcendental functions

See MouseOver in Wikipedia.

Sine

DSolve[u[x]==u''''[x],u[x],x]

The sine is its own fourth derivative.

DF[Sin,4]

SD[Sin,2,-2Pi,2Pi,-1.1,1.1,400]

SD[Sin,4,-2Pi,2Pi,-1.1,1.1,400]

Manipulate[
SD[Sin[a #+b]&,4,-2π,2π,-3.6,3.6,400],
{{a,1},-1.5,1.5,Appearance->"Open"},
{{b,0},-2 π,2 π,Appearance->"Open"},
SaveDefinitions->True]

Cosine

The cosine is its own fourth derivative.

DF[Cos,4]

SD[Cos,4,-2Pi,2Pi,-1.1,1.1,400]

Sine + Cosine

splusc[x_]:=Sin[x]+Cos[x]

DF[splusc,4]

SD[splusc,4,-2Pi,2Pi,-2.1,2.1,400]

Sine times Cosine

Note how the amplitude gets bigger with each derivative

sxc[x_]:=Sin[x]Cos[x]

DF[sxc,4]

SD[sxc,4,-2Pi,2Pi,-4.1,4.1,400]

Tangent

Pi/2//N

The derivatives all contain an occurrence of Tangent, and since the cos(π/2) is zero, the function and all its derivatives have asymptotes at odd multiples of π/2.  The graph shows four of the asymptotes (vertical lines).

TO DO : Something funny happens with the fourth derivative. Find out what the # %*@is going on.

DF[Tan,4]//TeXForm

SD[Tan,4,-4.9,4.9,-3,5,400]

tanover2[x_] := Tan[x/2]

DF[tanover2,5]

SD[tanover2,5,-Pi,Pi,-4,4,250]

Secant

The vertical lines are the asymptotes.

secant[x_]:=1/Cos[x]

DF[secant,5]

SD[secant,5,-4.9,4.9,-4,4,400]

secsq[x_]:=1/(Cos[x])^2

ArcTangent

The number of critical points is 0 for the function, 1 for the first derivative, 2 for the second derivative, and increments that way at least thru the 5 th derivative.  Exercise : Prove it always happens!

DF[ArcTan,5]

DF[ArcTan,5]//TeXForm

SD[ArcTan,5,-4,4,-5,5,450]

Exponential

the exponential function

The exponential function is its own derivative

DF[Exp,6]

SD[Exp,1,-3,2,-.4,6,200]

modified slightly to spread the derivatives out

expmod1[x_]:=Exp[.8x]

DF[expmod1,6]

SD[expmod1,6,-2,2,-.4,5,200]

Manipulate[
SD[Exp[a #]&,6,-2,2,-5,5,100],
{{a,1},-1.5,1.5,Appearance->"Open"},
SaveDefinitions->True]

A function that is its own second derivative

DSolve[u''[x]==u[x],u[x],x]

ownsd[x_]:=Exp[x]+Exp[-x]

DF[ownsd,2]

SD[ownsd,2,-2,2,-2,5,200]

notherexp[x_]:=Exp[x]-Exp[-x]

DF[notherexp,6]

fourthexp[x_]:=Exp[x]-Exp[-x/2]

DF[fourthexp,6]

Manipulate[
SD[Exp[-a #]+Exp[b #]&,6,-2,2,-5,5,100],
{{a,1},-1.5,1.5,Appearance->"Open"},
{{b,1},-1.5,1.5,Appearance->"Open"},
SaveDefinitions->True]

A function that is its own third derivative

TO DO : This function has very complicated behavior left of 0 that I don' t understand because it takes on extreme values that I cannot plot.

DSolve[u'''[x]==u[x],u[x],x]

owntd[x_]:=(E^x) +(E^(-x/2))  Cos[(((Sqrt[3]) x)/2)]

Manipulate[owntd[x],{x,-50,2,Appearance->"Open"}]//N

DF[owntd,4]

SD[owntd,3,-6.4,4,-7.5,13.2,200]

SD[owntd,3,-50,50,-70,50,300]

Log

Log

Log[x]

DF[Log,6]

GT := 2

SD[Log,6,0.01,11,-4,4,350]

Log to base 10

log10[x_] := Log[10,x]

DF[log10,6]

SD[log10,6,0.01,11,-4,4,400]

x times log

xxlog[x_] := x Log[x]

DF[xxlog,5]

SD[xxlog,5,0.01,5,-4,4,300]

Log over x

logoverx[x_]:=Log[x]/x

DF[logoverx,6]

SD[logoverx,6,0.01,4,-3,4,250]

Miscellaneous combinations

Sum of a polynomial and Sine

spsine[x_] := 2+(1/30)(x-3)^2+Sin[ x]

DF[spsine,5]

Note that the first derivative (red) is rising slowly.

SD[spsine,5,-20,20,-3,20,500]

Rational times Sin

RatSin1

ratsin1[x_] := (4/(x-1) ) Sin[x]

DF[ratsin1,5]

The vertical purple line is an asymptote

SD[ratsin1,5,-4 Pi,4Pi,-7,7,600]

RatSin2

This one, unlike the one above, has no asymptote.  What gives?? Answer: At 0, the value of the function has the form 0/0 so it is undetermined.  That means the point (0,4) is not on the graph of the function. (Similar statements are true of the derivatives). Of course, you can't see the hole! .

If you define Ratsin2[0] := 4 the result is that ratsin2 is continuous at 0, as both the graph and the table below suggest

ratsin2[x_] := (4/x ) Sin[x]

ratsin2[0]

Table[{n/10,ratsin2[n/10]},{n,{-10,-9,-7,-6,-5,-4,-3,-2,-1,1,2,3,4,5,6,7,8,9,10}}]//N//TableForm

{ratsin2[-(1/10)],ratsin[0],ratsin[(1/10)]}

DF[ratsin2,5]

SD[ratsin2,5,-4 Pi,4Pi,-7,7,600]

RatSin3

No asymptote problem here.  The denominator of the fraction is never 0.

ratsin3[x_] := (3/(x^2+1))  Sin[x]

DF[ratsin3,5]

SD[ratsin3,3,-2 Pi,2Pi,-5.1,5.1,400]

Sine of a polynomial

f[x_] := Sin[x^2-1]

ShowDerivatives[f,2,-2, 2]

g[x_] := 2 x

Plot[{f[x],f'[x], g[x]},{x, -3, 3}, PlotRange -> {-6,6}, ImageSize -> {200,2 200}, AspectRatio->2, Prolog->AbsoluteThickness[GT],PlotStyle->{RGBColor[0,0,1],RGBColor[1,0,0],RGBColor[0,0,0]}]

Plot[{f[x],f'[x], g[x]},{x, -4,4}, PlotRange -> {-8,8}, ImageSize -> {300,2 300}, AspectRatio->2, Prolog->AbsoluteThickness[GT],PlotStyle->{RGBColor[0,0,1],RGBColor[1,0,0],RGBColor[0,0,0]}]

Plot[{f[x],f'[x]},{x, -4, 4}, PlotRange -> {-9,9}, ImageSize -> {200,2 200}, AspectRatio->2.25, Prolog->AbsoluteThickness[GT],PlotStyle->{RGBColor[0,0,1],RGBColor[1,0,0],RGBColor[0,1,0]}]

ArcSin

f[x_] := ArcSin[x]

DF[f,5]

SD[f,4,-1,1,-2,3,200]

Remove[f]

ArcSec

f[x_]:=ArcSec[x]

DF[f,5]

SD[f,5,1,5,-3,3,300]

Remove[f]

x times sin

f[x_] := x Sin[x]

SD[f,5,-7,7,-9,9]

SD[f,5,-9,9,-9,9.5,300]